<template>
  <div class="app-container">
    <el-form label-width="120px">
      <el-form-item label="标题">
        <el-input v-model="event.data.title" />
      </el-form-item>
      <el-form-item label="内容">
        <el-input v-model="event.data.detail" :rows="10" type="textarea" />
      </el-form-item>

      <el-form-item>
        <el-button
          :disabled="saveBtnDisabled"
          type="primary"
          @click="sendMessage"
        >
          保存
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import messageApi from '@/api/message'
export default {
  data() {
    return {
      event: {
        topic: "system",
        userId: "0",
        entityType: 1,
        entityId: "1",
        entityUserId: "0",
        data: {
          title: "",
          detail: ""
        }
      },
      BASE_API: process.env.VUE_APP_BASE_API,
      saveBtnDisabled: false // 保存按钮是否禁用,
    }
  },

  //页面渲染成功
  created() {
  },

  methods: {
    // 新增数据
    sendMessage() {
      this.saveBtnDisabled = true
      // debugger
      messageApi.sendSysMsg(this.event).then(response => {
        this.$message({
          type: 'success',
          message: response.message
        })
        this.$router.push('/message/list')
      })
    },
  }
}
</script>
